﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Admin_Index_Left_Menu : OTS.AdminBasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            LoadMenu();
        }
        
    }
    private void LoadMenu()
    {
        OTS.BLL.SysRoseBLL srBLL = new OTS.BLL.SysRoseBLL();
        DataTable dt = srBLL.GetAllSysRight();
        if (dt.Rows.Count > 0)
        {
            OTS.Model.SessionUser sUser = this.getSessionUser(HttpContext.Current);
            if (sUser == null)
                Response.Redirect("error.htm");
            List<int> userRightList = sUser.myright;
            List<OTS.Model.sys_right>  tempList1 = new List<OTS.Model.sys_right>(); //品牌管理
            List<OTS.Model.sys_right>  tempList2 = new List<OTS.Model.sys_right>(); //商品管理
            List<OTS.Model.sys_right>  tempList3 = new List<OTS.Model.sys_right>(); //销售管理
            List<OTS.Model.sys_right>  tempList4 = new List<OTS.Model.sys_right>(); //系统管理
            int rtType,rtid;
            foreach (DataRow dr in dt.Rows)
            {
                rtid = int.Parse(dr["rtid"].ToString());
                if(userRightList.Contains(rtid))
                {
                    rtType = int.Parse(dr["rtType"].ToString());
                    OTS.Model.sys_right sr = new OTS.Model.sys_right();
                    sr.rtid = rtid;
                    sr.rtname = dr["rtName"].ToString();
                    sr.rturl = dr["rtUrl"].ToString();
                    sr.rttype = rtType;
                    switch (rtType)
                    {
                        case 1:
                            tempList1.Add(sr);
                            break;
                        case 2:
                            tempList2.Add(sr);
                            break;
                        case 3:
                            tempList3.Add(sr);
                            break;
                        case 4:
                            tempList4.Add(sr);
                            break;
                    }
                }

            }

            Repeater1.DataSource = tempList1;
            Repeater1.DataBind();
            Repeater2.DataSource = tempList2;
            Repeater2.DataBind();
            Repeater3.DataSource = tempList3;
            Repeater3.DataBind();
            Repeater4.DataSource = tempList4;
            Repeater4.DataBind();
        }

    }
}
